<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="imports.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" media="screen" type="text/css" title="style"
	href="style.css" />
<title>Gestion des livres</title>
</head>
<body>

	<c:if test="${sessionUser.role != 'ADMIN'}">
		<jsp:forward page="/m" />
	</c:if>
	<div id="wrapper">
		<div id="header">
			<div id="logo">
				<h1>e-commerce de livres</h1>


			</div>

		</div>
		<!-- end #header -->
		<div id="menu">
			<jsp:include page="header.jsp" />
		</div>
		<!-- end #menu -->
		<div id="page">
			<div id="page-bgtop">
				<div id="page-bgbtm">


					<div id="content">

						<div class="post">
							<h2 class="title">Gestion des livres</h2>
							<div class="entry">


								<c:if test="${fn:length(registrationMessage) == 0}">
									<p>
										Veuillez introduire les références du livre. <br />
										<br />
									</p>
								</c:if>
								<c:if test="${fn:length(registrationMessage) == 1}">
									<p>L'enregistrement n'a pas pu se faire pour la raison
										suivante :</p>
									<p>${registrationMessage[0]}</p>
								</c:if>
								<c:if test="${fn:length(registrationMessage) > 1}">
									<p>L'enregistrement n'a pas pu se faire pour les raisons
										suivantes :</p>
									<ol>
										<c:forEach var="text" items="${registrationMessage}">
											<li>${text}</li>
										</c:forEach>
									</ol>
								</c:if>
								<p></p>

								<form method="post" action="ArticleRegistration">
									<fieldset>
										<legend>
											<c:choose>
												<c:when test="${editArticle == true}">
													Modification des informations
												</c:when>
												<c:otherwise>
													Nouveau livre
												</c:otherwise>
											</c:choose>
										</legend>
										<c:if test="${articleRegistration.id != null && articleRegistration.id != 0}">
											<input type="hidden"  name="articleId"  value="${articleRegistration.id}">
										</c:if>
										<table>
											<tr>
												<td><label for="title">Titre : </label>
												</td>
												<td><input type="text" name="title" id="title" size="70" maxlength="200"
													value="${articleRegistration.title}" /></td>
											</tr>
											<tr>
												<td><label for="author">Auteurs : </label></td>
												<td><input type="text" name="author" id="author" size="70" maxlength="200"
													value="${articleRegistration.author}" /></td>
											</tr>
											<tr>
												<td>Genre(s) :</td>
												<td>
													<table>
														<tr>
															<c:forEach var="genre" items="${genres}" varStatus="genreCount">
																<c:if test="${genreCount.count % 5 == 0}">
																	</tr><tr>
																</c:if>
																<td>
																	<c:choose>
																		<c:when test="${articleRegistration.genres.contains(genre)}">
																			<input type="checkbox" name="genres" value="${genre}" id="${genre}" checked="checked"/>
																		</c:when>
																		<c:otherwise>
																			<input type="checkbox" name="genres" value="${genre}" id="${genre}"/>
																		</c:otherwise>
																	</c:choose> 
																	<label for="${genre}">${genre}</label>
																</td>
															</c:forEach>
															<c:if test="${fn:length(genres)%4 != 0}">
																<c:forEach var="n" begin="${fn:length(genres)%4}" end="3">
																	<td></td>
																</c:forEach>
															</c:if>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td><label for="genresPlus">Genres supplémentaires : </label></td>
												<td>
													<table>
														<tr>
															<td>
																<input type="text" name="genrePlus1" id="genrePlus" size="20" maxlength="40" />
															</td>
															<td>
																<input type="text" name="genrePlus2" id="genrePlus" size="20" maxlength="40" />
															</td>
															<td>
																<input type="text" name="genrePlus3" id="genrePlus" size="20" maxlength="40" />
															</td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td><label for="summary">Résumé : </label></td>
												<td><textarea name="summary" id="summary" rows="5" cols="51" >${articleRegistration.summary}</textarea></td>
											</tr>
											<tr>
												<td><label for="price">Prix : </label></td>
												<td><input type="text" name="price" id="price" size="30" maxlength="8" value="${articleRegistration.price}"/></td>
											</tr>
											<tr>
												<td><label for="year">Année : </label></td>
												<td><input type="text" name="year" id="year" size="30" maxlength="4" value="${articleRegistration.year}"/></td>
											</tr>
											<tr>
												<td><label for="stock">Stock : </label></td>
												<td><input type="text" name="stock" id="stock" size="30" maxlength="8" value="${articleRegistration.stock}"/></td>
											</tr>
											<tr>
												<td><label for="editor">Éditeur : </label></td>
												<td><input type="text" name="editor" id="editor" size="30" maxlength="200" value="${articleRegistration.editor}"/></td>
											</tr>
											<tr>
												<td><label for="language">Langue : </label></td>
												<td><input type="text" name="language" id="language" size="30" maxlength="40" value="${articleRegistration.language}"/></td>
											</tr>
											<tr>
												<td><label for="isbn">ISBN : </label></td>
												<td><input type="text" name="isbn" id="isbn" size="30" maxlength="13" value="${articleRegistration.isbn}"/></td>
											</tr>
										</table>
									</fieldset>
									<br />
									<input type="submit" value="Enregistrer" />
								</form>
							</div>
						</div>

						<div style="clear: both;">&nbsp;</div>
					</div>
					<!-- end #content -->
					<div id="sidebar">
						<ul>
							<jsp:include page="admin.jsp" />
							<jsp:include page="categories.jsp" />



						</ul>
					</div>
					<!-- end #sidebar -->
					<div style="clear: both;">&nbsp;</div>
				</div>
			</div>
		</div>
		<!-- end #page -->
	</div>
	<div id="footer">
		<p>Copyright (c) 2011. All rights reserved.</p>
	</div>
	<!-- end #footer -->
</body>
</html>



